﻿using System;
using Ex04.Menus.Delegates;

namespace Ex04.Menus.Test
{
    public static class DelegateTester
    {
        public static void Test()
        {
            MainMenu mainMenu = new MainMenu("My Menu");

            MenuItem action1 = new MenuItem("Action1");
            action1.Selected += new SelectionDelegate(Action1);

            MenuItem menuItem1 = new MenuItem("Sub-Menu 2");
            MenuItem action3 = new MenuItem("Action3");
            action3.Selected += new SelectionDelegate(Action3);
            menuItem1.AddMenuItem(action3);
            MenuItem menuItem3 = new MenuItem("Sub-Menu 2-2");
            menuItem1.AddMenuItem(menuItem3);
            MenuItem action4 = new MenuItem("Action4");
            action4.Selected += new SelectionDelegate(Action4);
            menuItem3.AddMenuItem(action4);
            MenuItem action5 = new MenuItem("Action5");
            action5.Selected += new SelectionDelegate(Action5);
            menuItem3.AddMenuItem(action5);
            MenuItem action6 = new MenuItem("Action6");
            action6.Selected += new SelectionDelegate(Action6);
            menuItem3.AddMenuItem(action6);
            MenuItem menuItem2 = new MenuItem("Sub-Menu 3");
            MenuItem action7 = new MenuItem("Action7");
            action7.Selected += new SelectionDelegate(Action7);
            menuItem2.AddMenuItem(action7);
            MenuItem action8 = new MenuItem("Action8");
            action8.Selected += new SelectionDelegate(Action8);
            menuItem2.AddMenuItem(action8);

            MenuItem action2 = new MenuItem("Action8");
            action2.Selected += new SelectionDelegate(Action2);

            //// add sub-menus to main menu created earlier
            mainMenu.AddMenuItem(action1);
            mainMenu.AddMenuItem(menuItem1);
            mainMenu.AddMenuItem(menuItem2);
            mainMenu.AddMenuItem(action2);

            mainMenu.Show();
            
        }

        public static void Action1()
        {
            Console.WriteLine("Action1 was performed");
        }

        public static void Action2()
        {
            Console.WriteLine("Action2 was performed");
        }

        public static void Action3()
        {
            Console.WriteLine("Action3 was performed");
        }

        public static void Action4()
        {
            Console.WriteLine("Action4 was performed");
        }

        public static void Action5()
        {
            Console.WriteLine("Action5 was performed");
        }

        public static void Action6()
        {
            Console.WriteLine("Action6 was performed");
        }

        public static void Action7()
        {
            Console.WriteLine("Action7 was performed");
        }

        public static void Action8()
        {
            Console.WriteLine("Action8 was performed");
        }
    }
}
